import moment from 'moment';

export const searchProps = [
  {
    type: 'input',
    value: 'institutionName',
    name: '机构名称',
    style: {
      width: '180px',
    },
    placeholder: '请输入',
  },
];

export const columns = [
  {
    title: '序号',
    dataIndex: 'index',
    width: 70,
    customRender: (text, record, index) => `${index + 1}`,
  },
  {
    dataIndex: 'institutionName',
    title: '机构名称',
    ellipsis: true,
    width: 200,
    customRender: (text) => text || '/',
  },
  {
    dataIndex: 'institutionShowName',
    title: 'app展示昵称',
    ellipsis: true,
    width: 200,
    customRender: (text) => text || '/',
  },
  {
    dataIndex: 'leadNotice',
    title: '负责人通知',
    ellipsis: true,
    width: 200,
    scopedSlots: { customRender: 'leadNotice' },
  },
  {
    dataIndex: 'phoneNumber',
    title: '负责人手机号',
    ellipsis: true,
    width: 200,
    customRender: (text) => text || '/',
  },
  {
    dataIndex: 'logo',
    title: '头像地址',
    ellipsis: true,
    width: 200,
    scopedSlots: { customRender: 'logo' },
  },
  {
    dataIndex: 'coin',
    title: '曝光数',
    ellipsis: true,
    width: 150,
    customRender: (text) => text === 0 ? 0 : (text || '/'),
  },
  {
    dataIndex: 'status',
    title: '启用状态',
    ellipsis: true,
    width: 150,
    scopedSlots: { customRender: 'status' },
  },
  {
    title: '操作',
    width: 150,
    align: 'center',
    fixed: 'right',
    dataIndex: 'operation',
    scopedSlots: {
      customRender: 'operation',
    },
  },
];

export const searchProps1 = [
  // {
  //   type: 'input',
  //   value: 'dealCoin',
  //   name: '曝光消耗',
  //   style: {
  //     width: '180px',
  //   },
  //   placeholder: '请输入',
  // },
  {
    type: 'select',
    value: 'dealType',
    name: '消耗类型',
    selectOptions: [
      {
        label: '增加',
        value: 0,
      },
      {
        label: '减少',
        value: 1,
      },
    ],
    placeholder: '请选择',
    style: {
      width: '180px',
    },
  },
  {
    type: 'date2',
    value: 'time',
    name: '提交时间',
    placeholder: '请选择',
    showTime: true,
    style: {
      width: '360px',
    },
  },
];

const typeMap = {
  0: '增加',
  1: '减少',
};

export const columns1 = [
  {
    title: '序号',
    dataIndex: 'index',
    width: 70,
    customRender: (text, record, index) => `${index + 1}`,
  },
  {
    dataIndex: 'institutionId',
    title: '机构ID',
    ellipsis: true,
    width: 200,
    customRender: (text) => text || '/',
  },
  {
    dataIndex: 'institutionName',
    title: '机构名称',
    ellipsis: true,
    width: 200,
    customRender: (text) => text || '/',
  },
  {
    dataIndex: 'dealType',
    title: '消耗类型',
    ellipsis: true,
    width: 150,
    customRender: (text) => typeMap[text] || '/',
  },
  {
    dataIndex: 'dealCoin',
    title: '曝光消耗',
    ellipsis: true,
    width: 150,
    customRender: (text) => text === 0 ? 0 : (text || '/'),
  },
  {
    dataIndex: 'remark',
    title: '备注',
    ellipsis: true,
    width: 180,
    customRender: (text) => text || '/',
  },
  {
    dataIndex: 'dealTime',
    title: '消耗时间',
    ellipsis: true,
    width: 180,
    customRender: (text) => text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '/',
  },
];
